﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.ComponentModel;
using System.Drawing;

namespace eTraining.Controls
{
    public class UpButton:Button
    {
        [Browsable(false)]
        public override string Text
        {
            get
            {
                return "成为专业用户!!!";
            }
        }

        private Color[] Colors = new Color[]
        {
            Color.Red,
            Color.Blue,
        };

        public UpButton()
        {
            tim.Enabled = true;
            tim.Interval = 300;
            tim.Tick+=new EventHandler(tim_Tick);

            this.Click += new EventHandler(UpButton_Click);


            this.ParentChanged += new EventHandler(UpButton_ParentChanged);
        }

        void UpButton_ParentChanged(object sender, EventArgs e)
        {
            this.Visible = !PublicObject.IsVIP;
        }

        void UpButton_Click(object sender, EventArgs e)
        {
            this.FindForm().Close();
        }

        public Timer tim = new Timer();

        private int idx = 0;
        private void tim_Tick(object sender, EventArgs e)
        {
            idx++;
            if (idx >= Colors.Length)
            {
                idx = 0;
            }

            if (idx % 2 == 0)
            {
                this.Font = new Font(this.Font.FontFamily, Font.Size, FontStyle.Bold);
            }
            else
            {
                this.Font = new Font(this.Font.FontFamily, Font.Size, FontStyle.Bold);
            }
            this.ForeColor = Colors[idx];

            Refresh();
        }
    }
}
